package com.simple.space.util;

import cn.hutool.crypto.digest.BCrypt;

/**
 * @ClassName BcryptUtil
 * @Author SimpleTree
 **/
public class BcryptUtil {
        public static String encode(String password){
            return BCrypt.hashpw(password, BCrypt.gensalt());
        }

        public static boolean match(String password, String encodePassword){
            return BCrypt.checkpw(password,encodePassword);
        }

    public static void main(String[] args){
        String password = "123456";
        String enPwd = "$2a$10$4cfPGv7bnsCxHwfnj.uQI.LC4fOizEnzGjwyWPWnuxvbwELUC/Exq";
        String psd = BcryptUtil.encode(password);
        System.out.println(psd);
        System.out.println(BcryptUtil.match(password, enPwd));
    }

}
